improved id handling and generating