Made the EnvelopeFactory infinitely more useable

The EnvelopeFactory now creates the correct type of Envelope object based on the
feedback from the server. Much more robust, much prettier. Well... Maybe not
prettier... Parsing is always nasty looking.