the selected codec is now read through the protocol headers; many bugfixes, code cleanup