encoder/decoder trap function type is now much simpler to use; added an example of custom traps.