Reduce number of evaluated queries.

Use 'for..empty' templatetag
Don't use |length filter if not reqired