Optimized some code and style.