Added various comments to functions