Move some more code over from cake utils.