fread and fwrite fixes as well as many other things.