Better handling of DOM properties

Fixes #1974, #1975