Fix several issues with adding tabs.