added most of the code from the FlickFinderV2 script.