Added basic spawn functionality and fixed a bug