Log in code cleanup