Refact init code.