Merge "Refactored base code to getDeviceForPortId"