Fixed throwing of errors at top-level code