Moved extraction and aggregation code into its own submodule.