private void removeUnitProduction(Grammar cfg) {
		//Initialize lists to keep track of the total unit productions removed, as well as the unit productions removed
		//for each state.
		ArrayList<String> totalRemovedUnitProductions = new ArrayList<String>();
		ArrayList<String> removedUnitProductionsPerState;
		ArrayList<State> states = (ArrayList<State>) cfg.getStates();
		
		for (State state: states) {
			//Re-initialize the list of removed unit productions per state for each state in the list of states.
			removedUnitProductionsPerState = new ArrayList<String>();
			for (String derivation: state.getDerivations()) {
				//This step checks if the derivation is a unit production, in which case it is added to both corresponding lists
				if (derivation.length() == 1 && Character.isUpperCase(derivation.toCharArray()[0])) {
					totalRemovedUnitProductions.add(derivation);
					removedUnitProductionsPerState.add(derivation);
				}
			}
			//If there were any unit productions found in the current state, remove the unit production, and add in any necessary
			//derivations to the state from which the unit production was removed.
			if (removedUnitProductionsPerState.size() > 0) {
				for (String toRemove: removedUnitProductionsPerState) {
					state.removeDerivation(toRemove);
					
					for (String derivation: cfg.getStateWithName(toRemove.toCharArray()[0])
							.getDerivations()) {
						
						if (!derivation.equals(toRemove)){
							state.addDerivation(derivation);
						}
					}
				}
			}
		}
		
		//Remove any empty states from the list of states in the grammar.
		cfg.removeEmptyStates();
	}