Fixed bugs on the code

Lots of crazy stuff showed up in the code. Everything fixed. I hope x.x