Changes and optimization in protocol handler