extracted more general pieces of overwrought codec