Added a bit of random sleep while waiting for database lock to avoid constant collisions.