Added logging functionality and fixed local login code