Updated with feedback from jsirois.