This function and the ones below need JSDoc.