EndOfEmit refactor