Fixed bug when using spaces in device name

This should fix the bug when you have a device name with a space in it.