Lot of bugfixes and introduction of template inheritance.