cleanup and code reformatting