code cleanup and login work