Refactored device discovery.
Get rid of pointers.