cleanup and speedup