Cleaning up and simplyfying

Dropping the dom-related parts
Simplyfying the code