Ported internal resume/yield and callHook functions, and implemented the unhandled exception handler.