Updating number of instances as necessary.