Bugfixes for auth infrastructure