Added average data to the as_json custome method for the year and overall.
Cosmetic changes and code refactoring. No functionality changes.