Code cleanup and docstring updates