PB export: Implement granularities and output file path calculation.
Move code around.
PB export: Some work on actual exporting.