huge performance improvement in template by also caching nil values
closing huge memory by calling #to_a on NodeSet + some small improvements