Fixed a bug in stack.py