less copying, refactor operations into encode/decode_context classes