Fixed a lot of bugs all over