Update wrapper.js

Reapplied modifications from PR #44.