Finished commenting and formatting code