Minor refactoring to eliminate redundant margin calculation.