Cleaning up discrete/continuous code