Landed with some cleanup and little fixes. Please test it and see if I broke anything in the process. I removed is_dir (and the po check which use it) because the return True was too much of an hack. Happy to consider a better fix for that as a separate patch. Thanks! Marco