temp table functions and select_by_year improvements