Refactor all I/O into UI class.