Fix a couple of bugs with label generation