Hoist some functions out