Refactor select generation.
Generate SQL using nodes, all at once.