Fixed delete object and spawn object code