Update login and logout handling.
Fix username sort.