matlab code fixup, removed global variables, genetic algorithm for parameter optimization