Tweaks and improvements to head spawning code