Refactoring encrypted messages and protobuffs