Fix npm support; tidy up