public Object insert(int index, Stage stage)
   throws IllegalArgumentException, IndexOutOfBoundsException {
      if (stages.containsValue(stage)) {
         throw new IllegalArgumentException();
      }
      if (wired != null || stage == null) {
         throw new IllegalStateException();
      }

      if (index < 0 || index > size()) {
         throw new IndexOutOfBoundsException();
      }

      // check that there is a non-empty set of common block-sizes
      Set set = stage.blockSizes();
      if (stages.isEmpty()) {
         if (set.isEmpty()) {
            throw new IllegalArgumentException("1st stage with no block sizes");
         }
      } else {
         Set common = this.blockSizes();
         common.retainAll(set);
         if (common.isEmpty()) {
            throw new IllegalArgumentException("no common block sizes found");
         }
      }

      Object result = new Object();
      stageKeys.add(index, result);
      stages.put(result, stage);

      return result;
   }