Made some optimizations