fixed several memory leaks caused by missing table_free calls