cleanup code
convert some instance variables to locals