merge wip-refactor branch