Removed debugging "return"; Add API key to write; Minor fixes.
Moved write.js to use the helpers, so that it could work in client-side code.