CRM-13550 previous didn't deal with empty very well

(these commits are all a bit of a pig's ear because I was rushing it & didn't want to have to run tests locally)