Added more smart autoclose