Improved support for dynamically generated DOM elements