Fixed issue with label generation.

In certain circumstances, labels were cached wrong and led to labels not
being inherited correctly.