Use namespace constants where needed.  Work on fixing up category selection.  Many other query functions fixed.