Updated authentication check. Misc housekeeping