support for unique/duplicate toggling in resultset
minor cleanup and refactor.
remove some debug comments