Changed !is_null($element) for null !== $element
Add trim to avoid whitespaces in elements attributes and idented some
classes.