#1016: use array_values to strip unwanted indicies. Use identity operator when checking if min_weight is undefined or not.