correction of some bugs with registration + template enhancement