Cleanup and add docstring.