Added beacon detection code.