Refactored some IO facilities.