First login and a bit of refactoring