Another attempt to fix the bug
Further refinements
Git cleanup
Added additional tests