Commented existing code

Added comments to relevant sections