remove active_tab_ref, name some of the anonymous functions, cleanup