Added some refactoring.