Fixes and speedups