Some math optimizations