Added a lot of work towards fixing the I/O layer