Rewrite of the portal script.