Some bugfixes in repair