Better handling of labels in sidebar. Closes #477