flushing stdout, improving print statements, and only checking validation when necessary