Small performance tweaks. Still experimenting.
Refactored a bunch of querying and snapshot stuff.
More refactoring.