Refs #8587 Refactoring and code tidy.