Fix bugs related to label creation

The commit messages describe the two issues.