Optimize velocity calculations.