Adding consistency to primary key discovery. Fixes #606.
Merge pull request #642 from recidive/fix-primary-keys

Adding consistency to primary key discovery. Fixes #606.