some minor changes, adding comments, removing logs etc.