add a template based version for faster computation, fix seed 0
Merge branch 'dcmt'