Docstring cleanup and small refactorings.