major (first) update to v2

originally was going to split functions up amongst various files, but
not ready for that. For now refactoring and cleaning up v1 code in C
and keeping in just two files.