fix weighted averages & cleanup