FIX: typo path -> dpath
FIX: typo path -> dpath
FIX: some obvious bugs, the logic is not checked. To be removed.