Clean up and some refinement