Fixed endless loop in BuildListOptimizer