refactoring

Messages and f.write's