moar refactoring of publish.js