WIP Refactoring codec