Refactored authentication service for more logical ordering of procedures.