Fix double link counting and invalid W computation.