Refactor state transition logic
Refactor terminal state logic in state transition
Throw only builtin JS errors as hard errors.

Only ReferenceErrors, SyntaxErrors, and the like will be thrown
from callbacks. All other errors will now be swallowed if not
handled from a terminal callback.

Fixes #290