Big round of cleanup, now that it works.