Cleaned up for newer versions of Python libraries