moved code from its temp home in cipollini to here. mchllweeks gets credit for a lot of this.