Check count on layer stack before trying to pop()