Some clean up and improvements over your pull request

It is a quick clean-up.
I think the profiles need to be split in the smaller chunks, and we need a better solution for the template compiler. But that will for later.