major rewrite and recoding of the free-time-zone algorithm