add template, and some other minor things