Reimplemented write_to_disk, wip