Code cleanup and formatting changes