Replace most uses of error() with assert()