Refactor stack.