Made a few optimizations