bugfix: remove entry if no more element in the array
unregister portId on destroy
bugfix: remove entry if no more item in array