My quick and dirty code so far. I'll clean it up some more after my work.