bugfixes and modifications to auth/deauth logic