login bugfixes
code cleanup cont.