A couple of optimizations and improvements.