Upgrade Cadence to 0.0.40.

Closes #389.