Refactoring and added XML doc comments.