refactor initialization of variables, clean up bogus code