Fix for wrong ref element generation. Merge from trunk. Bug: 17979117