some critical optimizations and reduction in generator expressions