major speed increase, cleanups