Code clean up and authentication class

Code clean up and authentication class