added free calls into malloc, sorted out python/c++ interop stuff