Made some minor optimizations here and there