Initial versions

just pulled in the files in their current state.
clean up

rearrange, add comments, and clean up.
(untested)