Added some fixes for Template maker.
Some refactoring.
Added ctemplate lib.
Merge from dev.