Adding support for custom envelopes, issue #5