Added functions to create variablesArray and labelsArray, fixed some bugs