Better login logging, refactoring