Fixed a crash when spawning