minor refinements and code cleanup