Update example code based on new factory pattern.