[CLEANUP] CGL issues and missing sql_free_result()