A few utility functions refactored and created.