Refactor
Fix error when changing libraries with a device connected