add comments and fix restart problem