Code cleanup and formatting updates