More cleanly abstract out the io and the different components.