Started integrating David's quad detection code