Fixed a lot of code