protocol fixes and encoding support for switch-protocols