Fixed multiple IO bugs