Busted the driver script into pieces.  I've been able to do adaptive refinement based on a curvature measure.