More changes to handling devices

-Can add and remove devices
- general improvements and bugfixes