I think these loops should be rewritten - first collect all dyes to a separate vector and check if there's a star (and store its position), then after the loop do the processing - copy start data and add fade colors.