Refactor mostly done.