Refactor to support PyPI packaging.