Refactoring some utilities.