Fixed a whole lot

fixed a lot of stuff in the code