Login & more refactoring