Fix race condition and support createRadialGradient

I've written a detailed analysis of the race condition on the commit message.

We should test for such race conditions. Please include the tests with this if you might, I may do that soon myself though. Thanks for making this! :smile: