Added error checking, fixed several major bugs.
Made things more modular. Rudimentary support for more graph types.