Use fewer DB queries
Merge branch 'master' of github.com:flack/openpsa
Fix warnings