Cleaned up most of the proof of compactness.