Removed unused distutils2 code and refactored some global functions to be local.