Move some initialization steps to init function.