Fixed some bugs in stack