add license and fix bug which prevented removing reference of a closed tab