Better handling of directories