gpl v2.  greatly modified from gpl v2 code found at www.scienceaddiction.com and ejohn.org