Write up most of the init function.