Added device state management, better error handling + demo version