Fix empty stack exceptions