Fix docstring and code cleanup