Refactor device_manager