Made some refactoring.