Fix removeAllChildren was not clearing pendingAdds array
Fix deadlock when a lock is already held under certain conditions (bug #171)