Fixed scoped lock for reference types.