Found reason for why calculated dm was wrong.

Used the wrong values in calculation. The values should not be multiplied by dm, this is the change, not the value deciding the step size. Should be correct now. Added a set of vars.