Add comments and edit code according to code conventions.