Reorganize, add docstring.