Merge pull request #5 from lovmoen/master

Problem: valgrind reports memleaks during selftest.