Extract init function.