Cleaned up getting of devices and using new query. #64