Added check for line length and residual. Something is wrong with the differences.