Fixes memory leaks.
Merge branch 'sdegutis/patch-1' into wincent

* sdegutis/patch-1:
  Fixes memory leaks.