fix small inf loop bug in the error handlers, and update some docs