diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java b/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java
index 91bdbff..64c2b8e 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java
@@ -165,127 +165,4 @@
         LinkResourceRequest request = builder.build();
         return request.resources().isEmpty() ? null : resourceService.requestResources(request);
     }
-
-    // FIXME refactor below this line... ----------------------------
-
-    /**
-     * Generates the series of MatchActionOperations from the
-     * {@link FlowBatchOperation}.
-     * <p>
-     * FIXME: Currently supporting PacketPathFlow and SingleDstTreeFlow only.
-     * <p>
-     * FIXME: MatchActionOperations should have dependency field to the other
-     * match action operations, and this method should use this.
-     *
-     * @param op the {@link FlowBatchOperation} object
-     * @return the list of {@link MatchActionOperations} objects
-     */
-    /*
-    private List<MatchActionOperations>
-            generateMatchActionOperationsList(FlowBatchOperation op) {
-
-        // MatchAction operations at head (ingress) switches.
-        MatchActionOperations headOps = matchActionService.createOperationsList();
-
-        // MatchAction operations at rest of the switches.
-        MatchActionOperations tailOps = matchActionService.createOperationsList();
-
-        MatchActionOperations removeOps = matchActionService.createOperationsList();
-
-        for (BatchOperationEntry<Operator, ?> e : op.getOperations()) {
-
-            if (e.getOperator() == FlowBatchOperation.Operator.ADD) {
-                generateInstallMatchActionOperations(e, tailOps, headOps);
-            } else if (e.getOperator() == FlowBatchOperation.Operator.REMOVE) {
-                generateRemoveMatchActionOperations(e, removeOps);
-            } else {
-                throw new UnsupportedOperationException(
-                        "FlowManager supports ADD and REMOVE operations only.");
-            }
-
-        }
-
-        return Arrays.asList(tailOps, headOps, removeOps);
-    }
-    */
-
-    /**
-     * Generates MatchActionOperations for an INSTALL FlowBatchOperation.
-     * <p/>
-     * FIXME: Currently only supports flows that generate exactly two match
-     * action operation sets.
-     *
-     * @param e Flow BatchOperationEntry
-     * @param tailOps MatchActionOperation set that the tail
-     * MatchActionOperations will be placed in
-     * @param headOps MatchActionOperation set that the head
-     * MatchActionOperations will be placed in
-     */
-    /*
-    private void generateInstallMatchActionOperations(
-            BatchOperationEntry<Operator, ?> e,
-            MatchActionOperations tailOps,
-            MatchActionOperations headOps) {
-
-        if (!(e.getTarget() instanceof Flow)) {
-            throw new IllegalStateException(
-                    "The target is not Flow object: " + e.getTarget());
-        }
-
-        // Compile flows to match-actions
-        Flow flow = (Flow) e.getTarget();
-        List<MatchActionOperations> maOps = flow.compile(
-                e.getOperator(), matchActionService);
-        verifyNotNull(maOps, "Could not compile the flow: " + flow);
-        verify(maOps.size() == 2,
-                "The flow generates unspported match-action operations.");
-
-        // Map FlowId to MatchActionIds
-        for (MatchActionOperations maOp : maOps) {
-            for (MatchActionOperationEntry entry : maOp.getOperations()) {
-                flowMatchActionsMap.put(
-                        KryoFactory.serialize(flow.getId()),
-                        KryoFactory.serialize(entry.getTarget()));
-            }
-        }
-
-        // Merge match-action operations
-        for (MatchActionOperationEntry mae : maOps.get(0).getOperations()) {
-            verify(mae.getOperator() == MatchActionOperations.Operator.INSTALL);
-            tailOps.addOperation(mae);
-        }
-        for (MatchActionOperationEntry mae : maOps.get(1).getOperations()) {
-            verify(mae.getOperator() == MatchActionOperations.Operator.INSTALL);
-            headOps.addOperation(mae);
-        }
-    }
-    */
-    /**
-     * Generates MatchActionOperations for a REMOVE FlowBatchOperation.
-     *
-     * @param e Flow BatchOperationEntry
-     * @param removeOps MatchActionOperation set that the remove
-     * MatchActionOperations will be placed in
-     */
-    /*
-    private void generateRemoveMatchActionOperations(
-            BatchOperationEntry<Operator, ?> e,
-            MatchActionOperations removeOps) {
-
-        if (!(e.getTarget() instanceof FlowId)) {
-            throw new IllegalStateException(
-                    "The target is not a FlowId object: " + e.getTarget());
-        }
-
-        // Compile flows to match-actions
-        FlowId flowId = (FlowId) e.getTarget();
-
-        for (byte[] matchActionIdBytes :
-            flowMatchActionsMap.remove(KryoFactory.serialize(flowId))) {
-            MatchActionId matchActionId = KryoFactory.deserialize(matchActionIdBytes);
-            removeOps.addOperation(new MatchActionOperationEntry(
-                    MatchActionOperations.Operator.REMOVE, matchActionId));
-        }
-    }
-    */
 }
