Fix code which is now running, but computations are probably wrong