Untested, likely broken code for devices.cpp.