Improve performance. Add type hints.