Improve login flow and other minor fixes.