Some math fixes