added tidy SQLConditional export; some code refactoring