Mostly global function definitions.