Added serialization and saving to json
Modified document modal + slight refactoring