Incorporated the whole rebasing algorithm. Unit tests pass, but no baselining system tests exist yet.