some code speedups