Corrected some write2disk bugs