added better errors
added better debugging support at invoke