Cleanup imports and use write-document.