Fixes to logging out process