Added sign out functionality and refactored a bit