Refactor some common helpers out