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
Test was 'work in progress' while I had fred smoke-testing it. Will probably delete it if I cannot fix it.