Added documentation of the error handling, and added the global variable debug for handling whether technical details are shown in the error page.