Cleaned up, commented and changed a bunch of stuff after reading over the code