Adds support for optional fields.

Optional fields are now represented using the scala option type. This closes #7.
should it be `foreach` rather than `map`?