Implemented selectTimeout and changed IO into MonadIO