Factor out a couple of useful helper functions.

5 files changed