Added imporved killswitch logic to library