Table order by date ascending, code cleanup