fix and improve modal handling
add initialize environment event
remove dynamic template loading as it is no longer supported
clean up events
use layout stored in environment