Fixed a bug in mwstack when next is empty.