Updated version of authorization. Fix bugs, redesign