Refactor require - to be merged at same time as DQX branch.