CORE 6133 refactoring and doc

* Made total bad function have named parameters
* improved names of query ctor functions
* documented public query ctor functions