Add comments and reformat code.