added template managment and some checking that the es actions happen correctly