More issues reported by Coverity

Mostly memory leaks, mostly pytohn related. Compile tested only.