Updated two-phase API and some clean-ups