Fixing the rebasing errors. This should be ready for pull request.

So after a broken rebase, this should be it, will remove dead code asap.