Factoring out common function
Fix source links regression since repack restructure.