Refactoring of save

see #8