Fix index check in `removeDefaultCapability`.