I wonder if we could extract these into ``_shared`` as general utility functions?