Simplify IO in main loop via macros.
Fix deprecation warnings.