Support for saving to disk and fixed a bug by @carlosIncuna