Merge pull request #676 from hintjens/master

Fixed memory leaks and other small cleanups
Need experimental space