Fix for login and cleanup