Fixed a shitton of bugs