Added refine query functionality.  Other minor changes.