Corrected several style errors and made some refactorization.