More coding; mostly advances in the detection script