Fix coverity issues (memleaks, copy-paste error)

Fixing memleaks from coverity (submitted a new build there yesterday)