Refactoring codec WIP 2
Refactoring codec WIP 3