Fix JS support for modules
Take care of module JS respecting recent module container changes

* Also improves generic tree behaviour