speed tweaks and optimizations