Fix for local lock reference counting on manual release of locks.