Adding documentation and renaming some vars