Fix parsing of protobuf format - needs some unit tests!