Use a global count for layer order management