move handleMessage into PortalInternal structure