Various fixes - Fix a minor bug in the previous change, concerning template parameters. Simplify a number of files - reduce duplication. Fix copyrights.