Fix locked check, which was totally broken, resulting in weird 403s

Fixes #2048