Making ring_dir() more bulletproof.