Migration to fragments and graph/table for revenue

This is very much still a mess, but the basic functionality is there, so merging. Needs cleaning up, redesign of some interfaces and more work in general.