Added comments at all possible place, Improved code structure