Properly dispose of strings returned from geometry.exportToX() methods.
Also moved call to set error handler to JS.