Add media validation, improve code readability, and fix bugs 79f86c4 hysts HF Staff commited on Mar 14