Refactor system detection.