Added comments, changed some stuff, added for debugging, I have no idea, it's 3.48 am and I hate everything.