Fixed bugs, and add Templates