Refactoring DOM access
bugfixes, refactorings