Fixed memory leaks
Merge remote-tracking branch 'pasis/memleak'
Merge remote-tracking branch 'origin/master' into plugins