Reorganize code, part 2.