Update and rename metaphor.js to twi.js

Initial adjustments to original code.