Refactored Engine to make SSO work