Added a few optimizations