Storing element ids with incrementing  values.

This is to avoid issues with duplicate ids. The identifier to generate
the preview text is now stored in it's own attribute.