Move most of the extension functions to pure functions.