Fixed unlocking to prevent crashing at invalid metrics