Fix some issues in autologin