added dump_state_tofile for code creation