Some optimizations to avoid recalculations.