Improved id handling.

Fixes #6