Added and removed a lot of unnecessary code