Merge pull request #1 from emwap/master

Fix memory leaks
calling memcpy for arrays (perhaps not on all occacions, still TODO) and free
Codegenerator overhaul