Moved some initialization steps around.