More refactoring

Just a number of small changes:

* Avoid unneded collection conversions
* Moved out inner classes (though, this may be a very personal taste,
  but doing so helped understand the code. I can undo it if people
  dislike this)
* A couple of classes renamed
* Got rid of the LazyCache class (the old behavior is now emulated by
  creating a new instance of `TemplateRegionsComputer` when calling
  `TemplateRegionParser.reset`).

Open points:

I still feel the code can be improved, but I don't feel confident doing
more refactoring as I can't fully follow all the manipulation happening
around the magic at and the braces.