made some improvements to the extract and flankstats code