Adds Corey's CSR generation function.

I should really learn to use the upstream better.