Cleaned up chart code