Fix bug when item has no tag

Note testing for typeof p.tags == "object" doesn't ensure it is not
null and therefore doesn't have length property.
Merge pull request #17 from olszowka/master