Added some optimizations