Rebuilt ObjectInputStream and ObjectOutputStream logic.