JBIDE-18247 - better organized with better cancelation logic

This is a cleaned up version of the patch with better cancelation logic. Also, see inline notes
how can this ever be -1 ? the getlastmodified returns 0 or a value afaics.