Fixed a crash on immediate re-login.

Fixes #155.