Refactored cell initialization code