GUI updates, sql query sort, refresh loop for sql query