Refactoring aggregates to catamorphs.

Better organized various catamorphs, introduced higher catamorphs.