Parameterize the contour mode.
Fix bugs in contour commit (eb5091)