Enhanced maintenance middleware to check user in an exception safe block
Added new variable to allow force secure urls in debug mode