PortalKit: finish functionality of build. But codes need refactor