Major IO cleanup

@JeffBezanson  Pull request as requested.