Added various comments and small code cleanup/organization