Extract steps in sepperate modules
Created by: szarsti
A simple re-factoring to allow for more convenient usage by other applications that may want to de-construct query and investigate accessed scope.
While re-factoring this bit I have added few case statements so alias expansion function will return error if alias for variable is not defined rather than crashing. This should help with reporting user errors when they do something wrong.