Bugfixes for authorization code