Moved stack functions to the stack object