Add dictionary for labels

Add dictionary for labels implemented as has table. Each rule only keeps
ids of labels in dictionary instead of whole label as a string.