Code clean-up for Python API.