Merge pull request #2 from csprunk/master

A few fixes for memory leaks found by Christoph Sprunk from U Freiburg.