Fixing memory leak

this set of commits contains a needed memory leak fix for 0.1