Fixed and improved socket writer/reader encryption.