added sum, cleaned up avg calculation
Merge Randy's changes.