Fix invalid uid being used after logoff. Thanks to Nigel Williams