minor modifications to preProcess script, more commentaries, better variable names etc