fix a few more memory errors
Merge remote-tracking branch 'origin/master'