Reformatted all the code. Much cleaner now