Refactoring towards simple optimizations