some renames, tidy ups and bugfixes whilst adding npm plugin