fix dir_prefix bug; move new/delete to unique_ptr