Updates to tern lib.  Tweaks to logic for figuring if tern server should be cleared