Fix some math logic.