cleanup and refinement