Merge pull request #117 from csmith/master

Some work on event formatting.
More formatter work.

Implement functions, add test.

Functions don't hugely need to be optional, we can just carry on
if the function is invalid.