Separate out some util functions in preperation for v3