Updated devices.cpp for shared pointers