Emergency fix for list building problem

Needs more work; but partial list rebuild is broken (probably because
queries are not store correctly). In old version, go to list, then view
book, then cancel and all headings were lost. Forcing full rebuild fixes
this, but is not a good long term solution.
Release changes 5.0.7 + emergency bug fix

- Fix to sql building code so that it correctly sets the 'where' clause