Added device retrieval and port selection for patching