General code cleanup and standardization