Partition lists when needed

Fixes #1022 
I need to remove it only if it has been added. Not if it is non-empty. So maybe pollLast doesn't work here.