Refactored initialization code.