Fixes some bugs with spawning.