Remove unused variable.
Rebuild properly the redeclaration chains.

When we removed the head of the redeclaration chain we didn't rebuild the whole
list, which resulted in not updated pointer of the most recent decl.
Implement sanity check, that ensures no lookup entries were left over.