Fixing a race condition bug during unboxing