Some reduction of duplication, and formatting for coding standard compliance.