Add support for directed graphs. Stylistic refactors.