Replaced what should be all instances of length() and distance() with lib.math.length.