General code formatting and cleanup