Fix and speedup.