adding a few more (albeit less monumental) speedups to the code