Merge "Add and use prepare_dir_with_policy() helper function"