Add all the code thus far

This isn't necessarily a good commit, since the code fails to work, but
it's a good starting point for future work.