Initialize and use device’s dev_id

As far as I see device_ptrs should be accessed by dev_id too. See commit message.