Make it run without crashing. Drift is unacceptably high.
Fix issue with NaNs: now check for NaN rather than 0 for out of range.
various work - esp eliminate -ve values!
final version used in project.