formatting changes and code cleanup