Fix coding style
Avoid accessing undefined variable

This is a hack. getElementDefinition() should never be called with an undefined URL.
Ensure properties are set before accessing them in the template

Also this is more or less a hack