MDL-29108 Removing global variables where they are not needed