source formatting
fix path mangling to not scribble over memory
move the device scanning code out into its own file