added threat detection, minor tweaks