adding debug statements and trying to clear unneeded variables to deal with thrashing