Cleanup malloc usage