CRAFTERCMS-89
Change algorithm for filtering out live items. Now filter is applied as part of db query.
Fixed additional sql query bugs.