This logic is straightforward, but it is shared with connections that also use pstc. Should this function be moved near the gen_weights etc?