Replace all assert()s with thrown exceptions.