change criteria for pending deletion insertion slightly
reorder code, more comments
delete pending deletion if it looks like it will never work.