optimizations and simplifications