Improved code - added protobuf support.