Memory problem fixes
Merge branch 'master' into coverity_scan