Implementation of documentRepair done

Implementation should be mostly done. Still completely untested, but
functionally looks sound. Will test shortly