formatting and minor code cleanup