A couple of optimizations (tested)