Setting up authentication etc.
Authentication related changes. Need to be tested.