Fixed a looooot of bugs