add template and makefile and solve a couple of problems