Refactoring to allow for AuthService.
Adding port resolution.