Refactoring of template compilation

Some refactorings and adjustments.

* Readme is updated with information about shared / invisible types
* refactored rake tasks, extracted code to a function that accepts a block to handle templates
* fixes handling of errors when parsing types, Compiler does not silently fail