Added sleep, fixed I/O