JS refactoring + fixed bug that caused wrong names on text and
annotation files in download packages