reworked read,write to have a better interface but will probably break some projects