Add sources from my other variant of the v1 version.
Merging in 2nd variant of original v1 implementation. Not working yet.