Big commit, don't know how much progress is in this one, check the git diff