Refactor stack into runtime