Reordered the middleware to correctly use the logger and errohandler

#183

<!---
@huboard:{"order":29.1875,"milestone_order":184,"custom_state":"ready"}
-->