Finish modularization and fix a couple minor hiccups.