clean up weighted sampling codes & support WeightVec as arguments