Code reformatted and optimized.