initial code commit.

after much reworking, this is ready for public use