Stacking machine refactored.