[wip] Some refactoring