Moved I/O functions into appropriate files to clean up code a little more