Added VitalyFedyunin's fix for empty emerald stacks.