Message factory

Adds a message factory for dynamic type handling. See examples/types.html for usage.