Auth improvements and code cleanup