Thats what i originally did. Tho i still think its more approriate to write it in Hy, since its contrib. I also do agree its a clusterfuck and hard to read. But i am not really sure how i can make it easier.
http://hastebin.com/nahikiciji.py