Some small optimizations and code reformatting.