add comments

add comments to to the code and change some methods to private