Clean up common X finding code.