Factor out more functions.