Refactor parameter checking to a middleware
Smarter error rendering