This isn't new code actually, copied directly from the old repo. I will try to clean it up a little.