more optimizations, massive speed improvement