cross-origin problems and changed dom structure

See commit messages for details