Rename error middleware
Improve error handling