It seems like this block is a no-op: If id==nil already, what does id=nil accomplish?  Am I missing something here?  Similarly for the several blocks below like this.