Locking fixes.
Some locking fixes, including a workaround for duplicated mounts.