code and formatting cleanup