bug fixes, speedups