Rework initialize function.