Refactoring I

modified the gcd implementation and added comments