Update:
It works!!! (well more or less)

There are a few bugs to work out, I should be able to work these out by myself, if I can't there is always you guys.