Complete redesign and rewrite based on DefaultPortal sample