Login functionality refactoring, routing improved