Fixed issue #4 - Scan for devices discovers too many divices

Also, added checks for null paths when applying commands in the tree