Reverted WriteRawBytes, added fixes based on comments