i/o logic has been moved to separate file.