improved initialization code