Filling in stack logic. Untested yet.