Move template load and compile outside of the endpoint function.  This seems to fix the issue where the template becomes inconsistent during a long run of the service.  This should be a bit more efficient... Though we should measure the memory usage at some point