Removed memory leak, thanks to diath for spotting it.
whoops, returning a free'd variable is really not what I meant...
Merge pull request #313 from CharmlessCoin/bug_fixes

Removed memory leak, thanks to diath for spotting it.