Initial, messy, undocumented code so far

This is the initial commit of the code, and is still very WIP.
Documentation and comments are all but nonexistent, but basic
functionality is working.