Did refactorings and code style improvements.