Code refactoring.

Only checks if the request is allowed if the maintenance file exists.
Less passing around of env and request.