Depending on the order of construction and destruction of val objects, count_emval_handles could be incorrect.