Some code cleanup to eliminate redundancy.