More code cleanup + reorg for ease of use in mass diffing client.