Rewriting arrays in  template queries to benefit from template caching; Minor typos in server side code