update_event_stats now does the right thing when it is handed over an empty material_id, also sorting materials in the stats page now