Implement get_package_index. Refactoring too!