Added some comments and fixed some bugs for score computation