[#1821] Fix IndexOutOfBoundsException which was thrown if the last component was removed but other components was left