Add some checking and code cleaning to Newton.