Refactoring round.

Split the protocol code from the semantics a bit. Use consistent parameter
passing over inconsistent passing. Use maps for passing many parameters
to functions and decode them explicitly.

This slowly forms a path towards a QuickCheck model of the code base as
we can begin to figure out how to test this system.