clean up code and formatted files. Alsoe added some comments