Move file writes to application server

Wherever possible.