Fixed some memleaks in fix_tabs