Code cleanup

More automatic memory management
Lower memory footprint for spawns