Bug fixing

I found an bugs in the file. I fixed it. Also I changed some stuff.