Bring in a bunch of changes from @jayj. Still more to come. This repo will be highly broken until I can get it finished.