Refactoring of the annotator.js encoder