Adds filter for labels (Fix #523)

This adds the filter for labels as requested at #523.  I've also optimized the class a little bit by consolidating the filters processed by the state into a single method and calling it from both methods building database queries.
Looks good.
I was on refactoring but if we can solve it this way, perfect :wink: