This commit is half broken.
I have to leave and don't want to redo what I have done so far.
Will squash later.