Refactor original code as a valid baseline.  Abandoning the rewrite until I understand the porblem better