Fix for crashing when setting device via -d command line parameter