Improved input/output handling