Added support for encoding and a behaviour spec.