Fixed the average queries to prevent divide by 0 errors.