javascript refactoring, improve templateing, start work on editor