Cleaned up httperror, moving some logic from the template to the model (where it should be).