Fix issues with labels API

Follows on from #9 and fixes issues raised in code review.