Fix terminal detection.