Added caching of averages so that they're not recalculated with every request. Removed unecessary debug logging from sorting.js