Make hash.write() code more conservative