add export and format features, code changes.