Max script generation: Remove some accidental redefinition of variables.
Max script generation: Added a method that returns a resolved model tree.
Max script generation: Reduced the size of the generated resolve function.