Better version detections and some cleanup.