This adds some more error checking options for development, and simplifies the control flow checks which now become debug asserts.