Refactored main control logic into hp3dx2