Added label merging and label caching