fix the memory leak problem mentioned in #26
Add legends right under the line graphs.
Merge pull request #38 from monnand/memleak

fix the memory leak problem mentioned in #26