Applied several optimizations