Changed to build word graph on the fly instead of pregenerating it.