Fix Pivot table losing its connection.

This hopefully fixes #1198 and while it doesn't solve the underlying problem mentioned in #1429, it does the tackle the resulting mess. :)
Merge pull request #1434 from franzliedke/patch-59

My take at #1198