Refactor utils

@jrf0110 thought I'd do a pull request for just this part now that things are working again.