core: Cleanup in errorhandler. Add some additional comments and remove obsolete code.
core: Add support for setting HTTP status code. Cleanup and added comments. Remove obsolete code.