Documented the methods and added comments.Did some refactoring and improved the code formating.