Fix issue 26

Fixes #26
Not sure if we should note somewhere (..in github?) that this code is only necessary for existing databases that have incorrectly inserted "duplicate" ids.