Simplifying logic and adding getPrincipal override.