Refactor and separate device logic from ui logic, and clean the code

User picture
User picture
User picture