WIP refactor runtime