Refactoring of the Aggregator.

Added the concept of transaction.
Moved some Snap helpers out to a new module.