Logic of login page, bugfixes