Refactor StackIO