Comments and minor refactoring