adding tracker for number of twins inserted per grain and adding lots of comments to the code