Commenting and minor refactoring