Moved all middleware out