Remove paintDocument() and add comments in main.