Let's actually move most of these utility function to `utils.js`.