Cleaned up IO functionality.
Cleaned up code.