cleanup and a couple improvements; the apparent deadlock seems to actually be running out of memory and slowing down to a crawl