Dump work-in-progress code into repo

THIS IS NOT FINISHED CODE. LOTS OF DEBUG STILL.

Version 4.0.0 is in the works. Rather than one big massive commit (like
this one, oops) when it's done, I'll commit as a I go like I should have
been doing in the first place.