Added support for plots and fixed a few bugs.