Refactor stacks