removed some unused code and added a few commentaries