Cleanup IO functions
unify io functions