Various changes on emit and tab closing