Almost done fixing the mathematics