Actually, the previous commit was just one big bug. This actually fixes the link-cleanhistory-problem