Better handling of function calls

Make sure that bad function calls fail safely, and failed function
calls don't leave spawned=true