polished authorization changes

Use _cleanup_ functions were possible.
Defer release to function's end.
Use one space before opening bracket of function.