Remove unneeded references to destroyOnClose
Remove unneeded checks and refactor element compiling