fix nested template invalidation, resolves #209