Refactoring, minor corrections.