Refactoring

Pull request for refactoring changes.