Fix a bunch of issues reported by coverity that seemed fairly stright forward and related to rendering