optimizations and code rationalization