Fixed some busted detection code.