* release Lock on map before trying to Lock NS * delete NS lock from map if no more refs. * refactor to avoid repetition of code.
Fixes #1393