Replaces elemento array by elemento vector
Moves global variables to proper scopes