Support for multiple instances running at the same time.

Now multiple instances can fetch data and try to insert it at the same
time. The first one succeeds and inserts by others are ignored.