added comments, made several methods private