Finished formatting of main code