Fixes for #16, #60

Fixes #16, #60 
The issue #16 occurs when you save parent and child templates interchangeably.
The issue #60 happens when you use ect together with koajs