fixes and speedups