PAHMA-1083: initial refactoring of portal code to support PAHMA.