Moved move global variables to args
Reorganized to prepare for parallelization
First parallelization of the expansion
Improvement to parallelization