add comments and cleanup