Reworked add/close tab logic a bit