I tried to split the changes in separate commits as cleanly as possible, each commit stands on its own.