Added local login, improved structure