speedup fix and cleanup