Codec fixes, working on passing unit tests