added error handler for 500 errors and loggers. Removed middleware.py