Exported extra internal functions for use by outside scripts.
Made some of the query helpers more robust.