Fixing a bug in encode repeated sub messages.