Cleaned up implementation of spawn