Fix import indexing issues

* In some cases, objects can exist in both `session.new` and
  `session.dirty`, so ensure we don't try to create duplicate index
  records.
`Cache` already stores sets, so no need to convert them
Make cache manage dirty so that clients benefit
Use common function to update indexes

Needed as multiple objects could be modified in a transaction, e.g.,
cascade deletes.
Merge pull request #380 from reciprocity/hotfix/fix-import-indexing

Fix import indexing issues
Merge remote-tracking branch 'origin/release/0.9a12' into develop