Replace the fancy Linq stuff with a simple loop for a big performance gain.