A quick commit of a refactor + first tests. Must revert back because random things are broken.