[wip] Refactoring

I'm still working on the rest of the abstractions, but this part is ok to be reviewed