Rearranged so that QUEST is implementable as a function
Merge branch 'patrick' into brett