Fixed a reference-counting problem in the external lock mechanism.