Fixed java.io.StreamCorruptedException issues