Refactored code, moved auth into default controller, added error logging