Added code to typemaps that eliminates memory leaks. Still need to check all other typemaps in CC3D code to make sure there are no leaks