Refactor some functions to use a central function, reducing technical debt.

Signed-off-by: Joshua Dickerson