Ugly lock, but it works.