Worked on this briefly. Still has one bug in it. 

Don't run this file until another patch fixes that bug.