Refactor JS libs; see websharks/s2member#177