Add stack item and lot of refactoring