Fixed the references to the previous array index as the DeviceID - instead, all have been changed to reference the $device->DeviceID.

Fixes #215