Clean up the code and improve performance to find all portal types with constraints