Cleaned up code that draws charts