Some code factoring.