Add extractEnvelope option to client

Rebase of PR #400.

I think I did this correctly...