Added debug-time sanity checks.