Implemented basic optimizations