Broke out initialization code into function.